class AddPageSlugs < ActiveRecord::Migration
  def self.up
    add_column :pages, :slug, :string if !Page.new.has_attribute?('slug')
    Page.reset_column_information
    for page in Page.find(:all)
      page.update_attribute('slug', Util::Slug.generate(page.name))
    end
  end

  def self.down
    remove_column :pages, :slug
  end
end
